from django.db import models


# Create your models here.

class Admin(models.Model):
    id = models.AutoField(primary_key=True) # id自动递增
    username = models.CharField(max_length=20) #字符串
    password = models.CharField(max_length=20) #字符串


class Press(models.Model):
    id = models.AutoField(primary_key=True)  # id自动递增
    pressname = models.CharField(max_length=50)  # 字符串
    pressaddress = models.CharField(max_length=50)  # 字符串


class Book(models.Model):
    id = models.AutoField(primary_key=True)  # id自动递增
    bookname = models.CharField(max_length=20)
    # max_digits整数有几位  ddecimal_places 小数有几位
    bookprice = models.DecimalField(max_digits=6,decimal_places=2)
    bookauther = models.CharField(max_length=10)
    bookimg = models.CharField(max_length=255)
    # 外键
    press = models.ForeignKey(to="Press",on_delete=models.SET_NULL,null=True,blank=True)


class BookType(models.Model):
    id = models.AutoField(primary_key=True) # id自动递增
    typename = models.CharField(max_length=20)
    # 多对多
    books = models.ManyToManyField(to="Book")
